package com.stone.back.dish.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.stone.back.dish.dao.IDishDao;
import com.stone.back.dish.entity.BfDish;
import com.stone.back.dish.entity.BfDishType;
import com.stone.base.entity.Page;

/**
 * 菜品管理
 * @author Stone P
 *
 */
@Service
public class DishService implements IDishService {
	@Autowired
	private IDishDao dishDao;

	/**
	 * 查询菜品分页信息
	 * @param pageNumber	页数
	 * @param dishChName	中文菜名
	 * @param dishEnName	英文菜名
	 * @param priceMin		单价
	 * @param priceMax		单价
	 * @param startDate		创建日期
	 * @param endDate		创建日期
	 * @return
	 */
	@Override
	public Page selectDishPage(int pageNumber, String dishChName, String dishEnName, String priceMin, String priceMax, 
			String startDate, String endDate, String dishTypeId) {
		return dishDao.selectDishPage(pageNumber, dishChName, dishEnName, priceMin, priceMax, startDate, endDate, dishTypeId);
	}
	
	/**
	 * 查询菜品分类列表
	 * @return
	 */
    public List<BfDishType> selectDishType() {
		List<BfDishType> list = this.dishDao.selectDishType();
		return list;
	}

	/**
	 * 增加菜品
	 * @param dish	菜品信息
	 * @return
	 */
	@Override
	public Integer addDish(BfDish dish) {
		Integer dishId = this.dishDao.addDish(dish);
		return dishId;
	}

	/**
	 * 修改菜品
	 * @param dish	菜品信息
	 * @return
	 */
	@Override
	public void updateDish(BfDish dish) {
		this.dishDao.updateDish(dish);
	}

	/**
	 * 查询菜品详情
	 * @param dishid	菜品Id
	 * @return
	 */
	@Override
	public BfDish selectDishDetail(int dishId) {
		BfDish dish = this.dishDao.selectDishDetail(dishId);
		return dish;
	}

	/**
	 * 删除菜品
	 * @param dishid	菜品Id
	 * @return
	 */
	@Override
	public void deleteDish(int dishId) {
		BfDish dish = this.dishDao.selectDishDetail(dishId);
		dish.setStatus(0);
		dishDao.updateDish(dish);
	}
}
